<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<!DOCTYPE HTML>
<html ng-app>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
    <title>${title}</title>
    <%@ include file="/WEB-INF/jsp/commons/meta.jsp" %>
    <link href="${ctx}/resources/new/style.css" type="text/css" rel="stylesheet"/>

</head>
<body>
<!-- 分页显示演示开始 -->
<form id="listForm" class="well form-search" action="${ctx}/point/setting" method="get">
    <input type="hidden" name="pageNo" id="pageNo" value="${pageData.pagination.pageNo}"/>
    <input type="hidden" name="fieldName" id="fieldName" value="${pageData.compositor.fieldName}"/>
    <input type="hidden" name="compositorType" id="compositorType" value="${pageData.compositor.compositorType}"/>
    <table class="table table-striped table-bordered table-condensed">
        <tr>
            <th align="left" valign="middle">
                商品名称|商品编码
                <y:search fieldType="S" fieldList="name,code" matchType="LIKE" className="input-medium search-query"/>
                <button class="btn btn-small" onclick="search()" type="button">
                    <i class="icon-search"></i>
                    搜索
                </button>
                <span class="pull-right" style="font-weight: normal;color: red;">盒装50分，听装100分</span>
            </th>
        </tr>
    </table>
</form>
<table class="table">
    <thead>
    <tr>
        <th>#</th>
        <th>
            <a href="javascript:sort('name')">商品名称</a>
        </th>
        <th>
            <a href="javascript:sort('code')">商品编码</a>
        </th>
        <th>
            <a href="javascript:sort('price')">单价</a>
        </th>
        <th>
            <a href="javascript:sort('point')">设定积分</a>
        </th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="entity" items="${pageData.result}" varStatus="index">
        <tr <c:if test="${!entity.visible}">bgcolor="#AFEEEE"</c:if>>
            <td>${index.index + 1}</td>
            <td>${entity.name}</td>
            <td>${entity.code}</td>
            <td>${entity.price}</td>
            <td>
                <form class="pointForm" action="${ctx }/point/save/setting/${entity.id }"
                      style="padding: 0px; margin: 0px;">
                    <input name="point" value="${entity.point}" type="text" class="span1"
                           style="color: red;margin: 0px;"  maxlength="5" />
                </form>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<%@ include file="/WEB-INF/jsp/commons/pager.jsp" %>
<script>
    $(function () {

        $(".pointForm").submit(function () {
            return false;
        });
        $(".pointForm").each(function () {
            var form = $(this);
            $(this).validate({
                rules: {
                    point: {
                        required: true,
                        number: true
                    }
                }
            });
            $("[name=point]", form).blur(function () {
                if (form.valid()) {
                    //form.serialize()
                    $.post(form.attr("action"), {point: $(this).val()}, function (data) {

                    }, 'json')
                }
            });
        });
    })
</script>
</body>
</html>